export const tableMixins = {
  data() {
    return {
      options: {},
      random: 1,
    }
  },
  computed: {
    transStyle() {
      return this.objToOne(this.options);
    },
    styleObj() {
      return {
        position: this.ispreview ? "absolute" : "static",
        width: this.transStyle.width + "px",
        height: this.transStyle.height + "px",
        tableHeight: this.transStyle.height - 36,
        tableHeightCopy: this.transStyle.height,
        left: this.transStyle.left + "px",
        top: this.transStyle.top + "px",
        background: this.transStyle.background,
        opacity: this.transStyle.transparency / 100,
      };
    },
  },
  //监控data中的数据变化
  watch: {
    value: {
      handler(val) {
        console.log(val)
        this.options = val;
        this.refresh();
      },
      deep: true,
    },
  },
  methods: {
    refresh() {
      this.random = new Date().getTime() * 1000 + (this.random++ % 1000);
    },
  },
  created() {
    this.refresh();
  },
}